/*
 public class ListNode {
    int val;
    ListNode next = null;

    ListNode(int val) {
        this.val = val;
    }
}
*/
public class Solution {
    public ListNode deleteDuplication(ListNode pHead) {
        ListNode newHead = new ListNode(-1);
        if(pHead == null) return null;
        ListNode pre = newHead;
        ListNode cur = pHead;
        while(cur != null){
            if(cur.next != null && cur.val == cur.next.val){
                while(cur.next != null && cur.val == cur.next.val){
                    cur = cur.next;
                }
                cur = cur.next;
            }else{
                pre.next = cur;
                cur = cur.next;
                pre = pre.next;
            }
        }
        if(pre.next != null){
            pre.next = null;
        }
        return newHead.next;
    }
}
